<?php
/**
 * Author   : 葫芦瓢子 <gourdladle@163.com>
 * Date     : 2023-07-03
 * Wechat   : skymouses
 * License  : MIT
 */

namespace GourdLadle\PhinxTp\seed;

use GourdLadle\PhinxTp\Phinx;
use think\console\Input;
use think\console\Output;
use think\console\input\Option;

class Run extends Phinx
{
    protected function configure()
    {
        $this->setName('phinx:seed:run')
            ->setDescription('执行数据迁移')
            ->addEnvironmentOption()
            ->addOption('seed', '-s', Option::VALUE_REQUIRED, '指定要执行数据迁移类');
    }

    protected function execute(Input $input, Output $output)
    {
        $commandName = 'seed:run';
        $arg = ['command'=>$commandName];
        $this->phinxEnvironmentOption($arg, $input);
        $input->hasOption('seed')
            && $arg['--seed'] = [$input->getOption('seed')];
        $this->runPhinx($commandName, $arg);
    }
}
